home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
comm
/
fido
/
shelter191a.lha
/
rexx
/
Browse.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-07-26
|
34KB
|
962 lines
/**/
v="$VER: Browse Rexx FileList Browser Williamson 55.63"
pview="PPDC" /* Viewer for PowerPacked files */
tview="PPDC" /* Viewer for plain text files */
search="Search NONUM" /* FileList Search command */
SinceLimit=36 /* Number of days back allowed for NewFiles,NewSince */
TimeLimit=12 /* Number of Browsing minutes allowed */
InputTimeout=45 /* Number of seconds to wait for user input */
MaxTimeouts=4 /* Maximun number of user timeouts permitted */
fileslist='MAIL:FILELISTS/01670104.LST'
freqlist='RAM:FREQ.LST'
config="CFG:Browse.CFG"
NOLIST='~(area.text|files.bbs|LZTEMP.#?|.info)'
LISTFMT='"%-20N%7L %-9D %C"';FLLEN=77;MARGINALL=45
tmpbbs="T:MLST"Pragma('ID')
tmpnew="T:NLST"Pragma('ID')
tmpsch="T:SLST"Pragma('ID')
newall="T:ALST"Pragma('ID')
matchlist="T:VLST"Pragma('ID')
temp="ram:"
tmplst="TLST"Pragma('ID')
script="File Stack Browser";sv="v"||right(v,5)
lf='0a'x;NL='0d'x||'0a'x;cls='0C'x||'0A'x;quote='"'
stacked=0;cstack="";ucmd="";x=""
NumString=2;OneChar=1;OneWord=0;AddCmd=1;DelCmd=0
direction.0="REVERSE";direction.1="FORWARD"
timeouts=0;timeup=0;notgrab=0
log=show('p','ROOFLOG')
if ~show("L", "rexxsupport.library") then
if ~addlib("rexxsupport.library", 0, -30, 0) then do
say "Couldn't access support.library !"
exit 20
end
if ~show("L", "RexxDosSupport.library") then
if ~addlib("RexxDosSupport.library", 0, -30, 0) then do
say "Couldn't access WB2 support.library !"
exit 20
end
options results
options failat 20
numeric digits 14
signal on halt
signal on ioerr
signal on break_c
signal on break_d
if arg()=0 then do
debug=1
ansi=1;expert=1;screen=20;page=40
username="Beta Tester";bytelimit=1440000
call open('bd','CON:1000/0/250/250/Browse Debug/AUTO/CLOSE/WAIT','w')
end;else do
debug=0
ansi=1;expert=1;screen=20;page=40
/* ansi=1;expert=0;screen=10;page=20 */
baseport=GetClip('SHELTER')
if baseport="ROOF" then envpath="";else envpath=baseport"/"
auxdev=GetVar(envpath||'AUXDEV',"G")
auxmount=GetVar(envpath||'AUXMOUNT',"G")
if ~showlist("H",auxdev) then do
options failat 99999
ADDRESS COMMAND auxmount
options failat 20
end
parse arg baud port bytelimit username
Address VALUE baseport||port
'String $(device) $(unit) $(locked) $(baudlocked)'
parse var RESULT device unit locked baudlocked .
if locked="TRUE" then redirect=GetVar(envpath||'AUXDIRECT',"G")||strip(device)'/'strip(unit)'/con/shared/checkcd/speed'||strip(baudlocked)
else redirect=GetVar(envpath||'AUXDIRECT',"G")||strip(device)'/'strip(unit)'/con/shared/checkcd/speed'||strip(baud)
end
uname=""
do i=1 to words(username)
if datatype(word(username,i),'N') then do
notgrab=1;iterate
end
uname=uname||word(username,i)" "
end
username=strip(uname);drop uname
if ~exists(freqlist) | ~exists(fileslist) | ~exists(config) then do
call Send(' Sorry, 'username' the sysop has not yet configured Browse'NL)
signal cleanup
end
/* Start Area Processing */
if ~open('dlst',config, 'R') then do
call send(" SYSTEM ERROR: Couldn't open fileareas list" config||NL)
signal cleanup
end
CSI='1b'x||'[';AOFF=CSI||'0m';BOLD=CSI||'1m';ITALICS=CSI||'3;40m'
invalid=" Invalid command"NL
nomarks=" There are no files marked for download"NL
call send(cls||ITALICS" "script sv||AOFF||NL||BOLD" by Robert Williamson 1:167/104.0@fidonet"AOFF||NL)
/* Start Area Processing */
sincedate=0;markedbytes=0;marks=0;mlist="";blist="";plist="";days=""
call send(' Welcome to 'script', 'username||NL)
call send(NL' Your current byte limit is 'bytelimit' bytes and your current'NL)
call send(' browsing time limit is 'timelimit' mins. There is a 'InputTimeout' second'NL)
call send(' timeout when waiting for your command input. Note that Browse will'NL)
call send(' terminate after after 'MaxTimeouts' timeouts.'NL||NL)
call getreturn
call send(' General Help'NL)
call send(' Type c;e;q to turn off Expert mode for more help, Longer menus'NL)
call send(' and shorter listings of areas and files.'NL||NL)
call send(' In all listings, the RETURN key pages in the current [D]irection.'NL)
call send(' Seems a lot of people have problems understanding what a Return Key is..'NL||NL)
call send(' When a prompt shows one of two choices in UPPERCASE, (Y/n) for example,'NL)
call send(' this is the default. The default is executed if you timeout or'NL)
call send(' enter an unexpected character.'NL)
call send(' Commands may be separated by spaces, commas or semicolons.'NL||NL)
call send(' The Stack is cleared if certain errors occur (Search,NewSInce)'NL)
call send(' Example: c;e q 23,n 1 m 1,2,3;q d;d'NL)
call send(' set expert menus, mark and download files 1 2 and 3 from'NL)
call send(' todays newfiles in area 23. If no newfiles, stack is cleared.'NL||NL)
call getreturn
call send(' Reading file area configuration.')
area=1
do while ~eof('dlst')
call send('.')
ln=strip(readln('dlst'))
if ln="" then iterate
parse var ln Number.area '"' Path.area '"' '"' Name.area '"' .
area=area+1
end /*eof*/
call close('dlst')
areas=area-1
call send(NL' Found 'areas' file areas'NL)
call send(' Browse Timer started'NL);call time('r')
maincmd:
if stacked then x=popstack(OneChar)
else do
if expert then ucmd=uprompt(NL||BOLD ,
||" [A]reas [S]earch [N]ewfiles [E]xit"NL ,
||" [D]ownload [C]hange [H]elp Select Area: "AOFF)
else do
call help_m('novice')
ucmd=uprompt(BOLD" Command: "AOFF)
end
stacked=pushstack(ucmd,AddCmd)
if stacked then x=popstack(OneChar);else x=upper(left(ucmd,1))
end
if x="D" then signal download
else if x="S" then call searchlist(pushstack(ucmd,DelCmd))
else if x="C" then do
call changeopt(pushstack(ucmd,DelCmd))
call send(cls)
end;else if x="N" then do
call newsinceall(pushstack(ucmd,DelCmd))
call send(cls)
end;else if x="H" then do
call help_m()
call send(cls)
end;else if x="E" then do
if marks>0 then signal download
else signal nomarkexit
end;else if datatype(x,"N") then do
call showarea(x)
signal maincmd
end;else if x="A" then do
call listareas(pushstack(ucmd,DelCmd))
end
signal maincmd
call cleanup
exit 0
listareas:
call send(cls)
if stacked then do
x=popstack(NumString)
if datatype(x,"N") & (x>0 & x<areas) then do
call showarea(x)
signal maincmd
end
end
display=1;scroll=1
do plines=1 to areas
if Name.plines='NAME.'plines then iterate
Number.plines=strip(Number.plines)
if length(Number.plines)=1 then call send(" "Number.plines" "BOLD||Name.plines||AOFF||NL)
else call send(" "Number.plines" "BOLD||Name.plines||AOFF||NL)
display=display+1
if display>screen | plines=areas then do
if stacked then x=popstack(OneChar)
else do
if expert then ucmd=uprompt(NL||BOLD ,
||" [N]ewfiles [S]earch [C]hange Menu [Q]uit to Main Menu"NL ,
||" [D]irection [H]elp Select Area or Hit Return Key to page "direction.scroll": "AOFF)
else do
call help_l('novice')
ucmd=uprompt(NL||BOLD" Hit Return Key to page "direction.scroll" Command: "AOFF)
end
stacked=pushstack(ucmd,AddCmd)
if stacked then x=popstack(OneChar);else x=upper(left(ucmd,1))
end
if datatype(x,"N") & (x>0 & x<areas) then do
call showarea(x)
signal maincmd
end;else if x="S" then call searchlist(pushstack(ucmd,DelCmd))
else if x="C" then call changeopt(pushstack(ucmd,DelCmd))
else if x="N" then call newsinceall(pushstack(ucmd,DelCmd))
else if x="H" then call help_l()
else if x="D" then scroll=~scroll
else if x="Q" then signal maincmd
else if x~="-" & x~="" then call send(invalid)
call send(cls)
display=1
if ~scroll then do
if plines>page then plines=plines-page;else plines=0
end
end
end
signal listareas
nomarkexit:
call send(nomarks)
if notgrab then call send(' Returning to system'NL)
else call send(' Returning to GRAB'NL)
call cleanup()
call delay(30)
exit 0
changeopt:
call send(cls)
do forever
if stacked then x=popstack(OneChar)
else do
if expert then ucmd=uprompt(NL||BOLD" [A]nsi [E]xpert [Q]uit to Main Menu: "AOFF)
else do
call help_c('novice')
ucmd=uprompt(NL||BOLD" Command: "AOFF)
end
stacked=pushstack(ucmd,AddCmd)
if stacked then x=popstack(OneChar);else x=upper(left(ucmd,1))
end
if x="Q" then return
if x="A" then do
ansi=~(ansi)
if ansi then do
CSI='1b'x||'[';AOFF=CSI||'0m';BOLD=CSI||'1m';ITALICS=CSI||'3;40m'
end;else do
CSI='';AOFF='';BOLD='';ITALICS=''
end
end
if x="E" then do
expert=~(expert)
if expert then do
screen=20;page=40
end;else do
screen=10;page=20
end
end
end
return
download:
if timeup then call send(BOLD' Your time is up'AOFF||NL)
if marks=0 then do
call send(nomarks)
if timeup then signal nomarkexit
else signal maincmd
end
call send(' You have selected 'marks' files, 'markedbytes' Bytes'NL)
do i=1 to words(mlist)
call send(" "right_justify(i,2)" "left_justify(word(mlist,i),24)" "right_justify(word(blist,i)" bytes",24)||NL)
end
bytesleft=bytelimit-markedbytes
if bytesleft>0 then call send(copies(" ",13)||"Bytes Remaining:"||right_justify(bytesleft" bytes",24)||NL)
if stacked then x=popstack(OneChar)
else do
if expert then ucmd=uprompt(NL||BOLD ,
||" [D]ownload [C]ontinue [U]nmark [A]bort"NL ,
||" [H]elp: "AOFF)
else do
call help_d('novice')
ucmd=uprompt(NL||BOLD" Command: "AOFF)
end
stacked=pushstack(ucmd,AddCmd)
if stacked then x=popstack(OneChar);else x=upper(left(ucmd,1))
end
if ~timeup & x="C" then signal maincmd
else if x="U" then do
if stacked then unmark=popstack(OneChar);else unmark=word(uprompt(" Select file number to Unmark: "),1)
if datatype(unmark,"N") & unmark~="" & (unmark < words(mlist)+1) then do
mlist=space(delstr(mlist,pos(word(mlist,unmark),mlist),length(word(mlist,unmark))+1),1)
blist=space(delstr(blist,pos(word(blist,unmark),blist),length(word(blist,unmark))+1),1)
marks=marks-1
markedbytes=0
do i=1 to words(blist)
markedbytes=markedbytes+word(blist,i)
end
end
signal download
end;else if x="H" then do
call help_d()
signal download
end;else if x="D" then do
if marks=0 then do
call send(nomarks)
if ~timeup then signal maincmd
end
if notgrab then do
call send(' Select GRAB on the Main Menu to download the files you have marked'NL)
call delay(50)
end
greq='Mail:Inbound/USERS/'translate(upper(strip(username)),'_',' ')||'.GRAB'
mlist=translate(mlist,'0a'x," ")
call open('req',greq,"W")
call writech('req',mlist)
call close('req')
call cleanup()
exit 1
end;else if x="A" then do
call send(' Clearing marked files list'NL)
signal nomarkexit
end;else if x~="-" & x~="" then call send(invalid)
signal download
return 0
showarea:
area=arg(1)
if Path.area="PATH."area | upper(strip(Path.area))="NULL:" then do
call ClrStackErr('Area 'BOLD||area||AOFF' does not exist')
return
end
call send(' Scanning Area:'area BOLD||Name.area||AOFF||NL)
areadir=addslash(dequote(Path.area))
las='PIPE LIST 'areadir||NOLIST' FILES NOHEAD LFORMAT 'LISTFMT' | SORT In: 'tmpbbs
address command las
call send(cls)
call wrapmark(tmpbbs)
return
searchlist:
call send(cls)
scmd:
if stacked then x=popstack(OneChar)
else do
if expert then ucmd=uprompt(NL||BOLD" [F]ile [D]esc [H]elp [Q]uit Search: "AOFF)
else do
call help_s('novice')
ucmd=uprompt(NL||BOLD" Command: "AOFF)
end
stacked=pushstack(ucmd,AddCmd)
if stacked then x=popstack(OneChar);else x=upper(left(ucmd,1))
end
if x="Q" then do
call send(cls)
return
end
if x="H" then do
call help_s()
signal scmd
end
if x="F" then do
if stacked then tofind=popstack(OneWord);else tofind=uprompt(' Enter AmigaDOS wildcard File search string: ')
if tofind="" then return
if pos('*',tofind)>0 then do
call send(' Please use standard AmigaDos wildcards'NL)
return
end
if pos('#?',tofind)=0 then do
call send(' AmigaDOs WildCard missing, adding default'||NL)
tofind=tofind'#?'
end
call send(' Searching for Files matching 'tofind||NL)
address COMMAND 'Fsearch >'matchlist freqlist tofind' -s'
if ~open('ml',matchlist,'r') then return
cmd=1;lstring.cmd=""
call open('x',tmpsch,'w');call close('x')
do while ~eof('ml')
fl=readln('ml')
if fl="!@ No match found" then do
call ClrStackErr(fl" for file:"tofind)
call close('ml')
return
end
fn=word(fl,2)
las='LIST 'lstring.cmd' NOHEAD LFORMAT 'LISTFMT' >>'tmpsch
if length(fn)+length(las)+1 >200 then do
cmd=cmd+1
lstring.cmd=""
end
lstring.cmd=lstring.cmd' 'fn
end
call close('ml')
do i=1 to cmd
las='LIST 'lstring.i' NOHEAD LFORMAT 'LISTFMT' >>'tmpsch
options failat 99;address command las;options failat 20
call delay(50)
end
call wrapmark(tmpsch)
end;else if x="D" then do
if stacked then tofind=popstack(OneWord);else tofind=word(uprompt(' Enter a keyword for Description search: '),1)
if tofind="" then return
call send(' Searching for Descriptions containing keyword:'tofind||NL)
address COMMAND search' >'matchlist fileslist tofind
if ~open('ml',matchlist,'r') then do
call ClrStackErr('!@ No match found for keyword:'tofind)
return
end
if ~open('x',tmpsch,'w') then return
discard=readln('ml')
do while ~eof('ml')
call writeln('x',delstr(readln('ml'),1,1))
end
call close('x');call close('ml')
call wrapmark(tmpsch)
end;else if x~="-" & x~="" then call send(invalid)
return
wrapmark:
thelist=arg(1)
if show('F','ifn') then call close('ifn')
if ~open('ifn',thelist,'R') then do
call ClrStackErr('SYSTEM Cannot open 'thelist' INFORM SYSOP')
return 0
end
if thelist=tmpsch then do
ltype='Search Match'
atitle=" "ltype" List"
end;else if thelist=newall then do
ltype='Global NewFiles'
atitle=" "ltype" List"
end;else if thelist=tmpnew then do
ltype='NewFiles Area'
atitle=" "ltype":"area Name.area
end;else do
ltype='File Area'
atitle=" "ltype":"area Name.area
end
tagged=0;tag=1;display=1
this_page_offset=0;last_page_offset=0
file_offset=0
this_page_tags=0;last_page_tags=0
scroll=1
if ~areacmd() then do
call close('ifn')
return 0
end
call send(cls)
do while ~eof('ifn')
line=readln('ifn')
this_page_offset=this_page_offset+(length(line)+1)
file_offset=file_offset+this_page_offset
if left(line,1)=":" then iterate
if left(line,1)=" " then do
call send(line||NL)
display=display+1
end;else do
file.tag=word(line,1)
bytes.tag=word(line,2)
call send(' 'wrap_line('['center(tag,3)']' line,FLLEN,MARGINALL))
tagged=tag
tag=tag+1
this_page_tags=this_page_tags+1
if display>=screen then do
if debug then do
call Kprint('Tag :'tag' Tagged :'tagged)
call Kprint('Page_Tags:'this_page_tags last_page_tags)
call Kprint('FilePos :'File_offset)
call Kprint('Offset :'this_page_offset last_page_offset)
end
if ~areacmd() then do
call close('ifn')
return 0
end
if ~scroll then do
seek_offset=this_page_offset+last_page_offset
file_offset=file_offset-seek_offset
tag=tag-(this_page_tags+last_page_tags)
tagged=tagged-(this_page_tags+last_page_tags)
if file_offset<0 | tag<0 | tagged<0 then do
tagged=0;tag=1;display=1
this_page_offset=0;last_page_offset=0;file_offset=0
this_page_tags=0;last_page_tags=0
call seek('ifn',0,'B')
end;else do
call seek('ifn',-seek_offset,'C')
if debug then do
call Kprint('Tag :'tag' Tagged :'tagged)
call Kprint('Page_Tags:'this_page_tags last_page_tags)
call Kprint('FilePos :'File_offset)
call Kprint('Offset :'this_page_offset'+'last_page_offset':'seek_offset)
end
end
end
display=1
last_page_offset=this_page_offset
last_page_tags=this_page_tags
this_page_offset=0;this_page_tags=0
if debug then do
call Kprint('Page_Tags:'this_page_tags last_page_tags)
call Kprint('Offset :'this_page_offset last_page_offset)
end
call send(cls)
end
end
end /*eof */
call close('ifn')
call send(' End of 'ltype' Listing'NL)
if areacmd('end') then call wrapmark(thelist)
return
areacmd:
if thelist=tmpsch | thelist=newall then do
notarea=1
aprompt=ITALICS||atitle||AOFF||NL||BOLD ,
||" [M]ark Files [D]irection [A]rea Menu [Q]uit to Main Menu"NL ,
||" [H]elp Hit Return Key to page "direction.scroll": "AOFF
end;else do
notarea=0
aprompt=ITALICS||atitle||AOFF||NL||BOLD ,
||" [M]ark Files [D]irection [A]rea Menu [Q]uit to Main Menuu"NL ,
||" [N]ew Since [V]iew [H]elp Hit Return Key to page "direction.scroll": "AOFF
end
do forever
if stacked then x=popstack(OneChar)
else do
if expert then ucmd=uprompt(aprompt)
else do
call send(atitle||NL)
call help_a('novice')
ucmd=uprompt(NL||BOLD" Hit Return Key to page "direction.scroll" Command: "AOFF)
end
stacked=pushstack(ucmd,AddCmd)
if stacked then x=popstack(OneChar);else x=upper(left(ucmd,1))
end
if x="Q" | x="A" then return 0
else if x="D" then do
scroll=~scroll
return 1
end;else if x="H" then call help_a()
else if x="N" & ~notarea then call newsince(pushstack(ucmd,AddCmd))
else if x="M" then do
if stacked then marked=popstack(NumString);else marked=uprompt(' Files:'marks 'Bytes:'markedbytes' Enter File number(s): ')
ucmd=""
do x=1 to words(marked)
y=word(marked,x)
if y<1 | y>tagged | ~datatype(y,"N") then do
call send(' Invalid mark 'y' ignored, try [H]elp'NL)
iterate
end;else if bytes.y+markedbytes>bytelimit then do
call Send(' Sorry, 'file.y bytes.y' bytes exceeds your 'bytelimit' byte limit'NL)
iterate
end;else do
markedbytes=markedbytes+bytes.y
blist=blist||bytes.y" "
mlist=mlist||file.y||" "
marks=marks+1
call send(' 'file.y bytes.y' bytes, Marked for Download'NL)
end
end
call getreturn
end;else if x="V" & ~notarea then do
if stacked then marked=PopStack(NumString);else marked=uprompt(' Enter number of file to view or list: ')
y=word(marked,1)
if y<1 | y>tagged | ~datatype(y,"N") then do
call send(' Invalid mark 'y' ignored, try [H]elp'NL)
end;else call viewfile(areadir||file.y)
call getreturn
end;else if x="" & arg(1)='end' then do
scroll=~scroll
call pushstack('D')
return 1
end;else if x~="-" & x~="" then call send(invalid)
else return 1
end
return 0
wrap_line:
if debug then term=lf;else term=nl
text=arg(1);rEdge=arg(2)/*line length*/;lEdge=arg(3)/*wrapmargin*/
newtext=''
do while length(text)>0
broken_word=0
if length(text)<rEdge then do
newtext=newtext||text||term
display=display+1;text=''
end;else do
tmptext=strip(text,l)
diff=length(text)-length(tmptext)
first_break=lastpos(' ',tmptext,rEdge-diff)
break_point=first_break+diff
if lEdge=break_point then do
break_point=rEdge-1
broken_word=1
end
newtext=newtext||strip(left(text,break_point),t)
if broken_word then newtext=newtext||'-'
newtext=newtext||term
display=display+1
text=copies(' ',lEdge)||strip(right(text,length(text)-break_point),l)
end
end
return newtext
getsince:
if stacked then days=popstack(OneChar);else days=uprompt(' How many days back? (1-'SinceLimit'): ')
if ~datatype(days,"N") | (days<=0 | days>SinceLimit) then do
call ClrStackErr("Days "days" must be > 0 and < "SinceLimit)
return 0
end
sincedate=space(date('n',date('i')-days),1,'-')
sincedate=left(overlay(substr(sincedate,10,2),sincedate,8,2),9)
return 1
newsinceall:
if sincedate~=0 & exists(newall) then do
ucmd=upper(uprompt(' View last 'days' days NewFiles list from 'sincedate'? (y/N): '))
if ucmd="Y" then do
call wrapmark(newall)
return
end
end
if ~getsince() then return
if stacked then dosort=popstack(OneChar)=="S";else dosort=upper(left(uprompt(" Alphabetically [S]orted (fast) or by [A]rea (slow): (s/A) "),1))=="S"
call Send(' Searching 'BOLD'ALL'AOFF' areas for new files received since 'BOLD||sincedate||AOFF||NL)
tmp="";tl=length(BOLD||AOFF)
savelist=(days=7 & ~dosort)
do area=1 to areas
if Path.area="PATH."area | upper(strip(Path.area))="NULL:" then iterate
if tmp~="" then do
if tl>0 then call send(copies('08'x,length(tmp)-tl))
else call send(copies('08'x,length(tmp)))
end
tmp=' Searching Area 'BOLD||Number.area||AOFF
if ~dosort then Address COMMAND 'Echo >>'newall' " Area 'BOLD||Number.area' 'ITALICS||Name.area||AOFF'"'
call send(tmp)
areadir=addslash(dequote(Path.area))
las='LIST 'areadir||NOLIST' SINCE' sincedate 'FILES NOHEAD LFORMAT 'LISTFMT' >>'newall
address COMMAND las
end
call send(NL)
if dosort then address COMMAND "SORT FROM "newall" TO "newall
if savelist then do
address COMMAND 'COPY 'newall' TO MAIL:FILELISTS/NEWFILES.LST'
call Send(' Updated Last 7 days NewFiles listing'||NL)
end
call wrapmark(newall)
return
newsince:
if ~getsince() then return 0
areadir=addslash(dequote(Path.area))
call Send(' Searching Area 'BOLD||Number.area||AOFF' for new files received since 'BOLD||sincedate||AOFF||NL)
las='PIPE LIST 'areadir||NOLIST' SINCE' sincedate 'FILES NOHEAD LFORMAT 'LISTFMT' | SORT In: 'tmpnew
address COMMAND las
if word(statef(tmpnew),2)>0 then call wrapmark(tmpnew)
else call ClrStackErr('None found')
return
viewfile:
fname=arg(1)
file=get_fn(fname)
if ~open('in',fname,'R') then do
call send(" Can't open" '"'file'"'NL)
call vcleanup
return
end;else do
buff=readch('in',8);call close('in')
select
when left(buff,4)=='ZOO ' then do
xcmd='zoo x'
lcmd='zoo >'tmplst' l'
end
when substr(buff,3,3)=='-lh' then do
xcmd='lha x'
lcmd='lha >'tmplst' vv'
end
when left(buff,1)=='1A'x then do
xcmd='arc x'
lcmd='arc >'tmplst' l'
end
otherwise cmd=tview
end
if cmd=tview then do
if ~displayable(fname) then call send(' File 'fname' does not seems to be displayable'NL)
else do
if debug then address COMMAND cmd fname
else address COMMAND cmd fname redirect
end
end;else do
call pragma('D',temp)
call send(" Please wait..listing archive"NL)
address command lcmd fname
call send(cls)
if debug then address COMMAND tview tmplst
else address COMMAND tview tmplst redirect
tname=uprompt(" Enter fullpath of file to read: ")
if tname~="" then do
call send(NL" Please wait, extracting "tname||NL)
address command xcmd fname tname
address COMMAND 'Protect >NIL: 'temp||tname' +d'
call send(cls)
cmd=tview
if ~displayable(temp||tname) then call send(' File 'tname' does not seems to be displayable'NL)
else do
if debug then address COMMAND cmd temp||tname
else address COMMAND cmd temp||tname redirect
end
end
call vcleanup
end
end
return
displayable:
if open('af',arg(1)) then do
h=readch('af',100)
call close('af')
if left(h,2)='PP' then do
cmd=pview
return 1
end;else if length(compress(h,xrange(' ','~')xrange('a0'x,'ff'x)'0a'x))<10 then return 1
end
return 0
cleanup:
call vcleanup()
call delete(matchlist)
call delete(tmpbbs)
call delete(tmpsch)
call delete(tmpnew)
call delete(newall)
return
vcleanup:
if exists(temp||tmplst) then call delete(temp||tmplst)
if exists(temp||tname) then call delete(temp||tname)
call pragma('D',olddir)
return
ClrStackErr:
call send(BOLD" Error:"AOFF||arg(1)" - Clearing command stack"||NL)
stacked=0;cstack=""
call getreturn
return
help_m:
if arg(1)~='novice' then call send(cls||BOLD||ITALICS' Main Menu Help'AOFF||NL)
else call send(NL)
call send(BOLD' Select Area Number 'AOFF' - 'ITALICS'Enter number to Select a file area'AOFF||NL)
call send(BOLD' [A]reas 'AOFF' - 'ITALICS'List available file areas'AOFF||NL)
call send(' 'ITALICS'You can page forwards and backwards'AOFF||NL)
call send(BOLD' [S]earch 'AOFF' - 'ITALICS'Search for a file by name or description'AOFF||NL)
call send(BOLD' [N]ewFiles 'AOFF' - 'ITALICS'List all files received in last N days'AOFF||NL)
call send(BOLD' [D]ownload 'AOFF' - 'ITALICS'List/DownLoad/Clear marked files'AOFF||NL)
call send(BOLD' [C]hange 'AOFF' - 'ITALICS'Change your ANSI, MENU, HELP Settings'AOFF||NL)
call send(BOLD' [E]xit 'AOFF' - 'ITALICS'If you have marked files, you will be'AOFF||NL)
call send(' 'ITALICS'prompted to DownLoad or Abort'AOFF||NL)
call send(' 'ITALICS'otherwise, returns to GRAB'AOFF||NL)
if arg(1)~='novice' then call getreturn
return
help_l:
if arg(1)~='novice' then call send(cls||BOLD||ITALICS' Area Menu Help'AOFF||NL)
else call send(NL)
call send(BOLD' Select Area Number 'AOFF' - 'ITALICS'Enter number to select a file area'AOFF||NL)
call send(BOLD' [D]irection 'AOFF' - 'ITALICS'Changes direction of areas list paging'AOFF||NL)
call send(' 'ITALICS'RETURN pages in direction selected'AOFF||NL)
call send(BOLD' [N]ewFiles 'AOFF' - 'ITALICS'List all files received in last N days'AOFF||NL)
call send(BOLD' [S]earch 'AOFF' - 'ITALICS'Search for a file by name or description'AOFF||NL)
call send(BOLD' [C]hange 'AOFF' - 'ITALICS'Change ANSI, MENU, EXPERT Settings'AOFF||NL)
call send(BOLD' [Q]uit 'AOFF' - 'ITALICS'Return to Main Menu'AOFF||NL)
if arg(1)~='novice' then call getreturn
return
help_a:
if arg(1)~='novice' then call send(cls||BOLD||ITALICS' File Menu Help'AOFF||NL)
call send(BOLD' [A]rea 'AOFF' - 'ITALICS'Go to Area List Menu'AOFF||NL)
call send(BOLD' [D]irection 'AOFF' - 'ITALICS'Changes direction of files list paging'AOFF||NL)
call send(' 'ITALICS'RETURN pages in direction selected'AOFF||NL)
call send(BOLD' [R]edisplay 'AOFF' - 'ITALICS'Show file list again if at End'AOFF||NL)
call send(BOLD' [N]ew Since 'AOFF' - 'ITALICS'List files in this area received in last N days'AOFF||NL)
call send(BOLD' [M]ark 'AOFF' - 'ITALICS'Mark file(s) for download'AOFF||NL)
call send(' 'ITALICS'Displays number of files and bytes marked'AOFF||NL)
call send(BOLD' [V]iew 'AOFF' - 'ITALICS'View a text file, the contents of an archive'AOFF||NL)
call send(' 'ITALICS'or a text file in an archive'AOFF||NL)
call send(' 'ITALICS'View is only valid in a FILE area'AOFF||NL)
call send(BOLD' [Q]uit 'AOFF' - 'ITALICS'Return to previous menu'AOFF||NL)
if arg(1)~='novice' then call getreturn
return
help_d:
if arg(1)~='novice' then call send(cls||BOLD||ITALICS' DownLoad Menu Help'AOFF||NL)
else call send(NL)
call send(BOLD' [C]ontinue 'AOFF' - 'ITALICS'Continue marking files'AOFF||NL)
call send(BOLD' [U]nmark 'AOFF' - 'ITALICS'Unmark and removed file from download list'AOFF||NL)
call send(BOLD' [D]ownload 'AOFF' - 'ITALICS'Gives list of files marked to GRAB'AOFF||NL)
call send(' 'ITALICS'for downloading to you'AOFF||NL)
call send(BOLD' [A]bort 'AOFF' - 'ITALICS'Marked list is cleared and you are'AOFF||NL)
call send(' 'ITALICS'returned to GRAB filename request prompt'AOFF||NL)
if arg(1)~='novice' then call getreturn
return
help_c:
if arg(1)~='novice' then call send(cls||BOLD||ITALICS' Change Menu Help'AOFF||NL)
else call send(NL)
call send(BOLD' [A]nsi 'AOFF' - 'ITALICS'Toggle ANSI Display'AOFF||NL)
call send(BOLD' [E]xpert 'AOFF' - 'ITALICS'Toggle Expert/Novice Menus'AOFF||NL)
call send(BOLD' [Q]uit 'AOFF' - 'ITALICS'Return to Main menu'AOFF||NL)
if arg(1)~='novice' then call getreturn
return
help_s:
if arg(1)~='novice' then call send(cls||BOLD||ITALICS' Search Menu Help'AOFF||NL)
else call send(NL)
call send(BOLD' [F]ile 'AOFF' - 'ITALICS'Search for a file by name, USE WILDCARDS'AOFF||NL)
call send(' 'ITALICS'You may mark files for download from match list'AOFF||NL)
call send(BOLD' [D]escription 'AOFF' - 'ITALICS'Search for a file by description, no WILDCARDS'AOFF||NL)
call send(' 'ITALICS'You CAN use a partial description'AOFF||NL)
call send(' 'ITALICS'You may mark files for download from match list'AOFF||NL)
call send(BOLD' [Q}uit 'AOFF' - 'ITALICS'Return to area menu'AOFF||NL)
if arg(1)~='novice' then call getreturn
return
getreturn: return uprompt(BOLD' Hit RETURN 'AOFF)
pushstack:
if arg(1)="UCMD" | arg(1)="" then return stacked
if cstack~="" then do
if arg(2)=DelCmd then cstack=strip(delstr(arg(1),1,length(word(arg(1),1))))
else cstack=cstack||" "||arg(1)
end;else do
if arg(2)=DelCmd then cstack=strip(delstr(arg(1),1,length(word(arg(1),1))))
else cstack=arg(1)
end
stacked=words(cstack)>0
ucmd=""
return stacked
popstack:
if cstack="" then do
stacked=0
return '-'
end
if arg(1)=NumString then do
py=""
do forever
if cstack="" then return strip(py)
px=word(cstack,1)
if ~datatype(px,'N') then return strip(py)
py=py||" "||strip(px)
if words(cstack)>1 then cstack=strip(delstr(cstack,1,length(px)))
else do
stacked=1;cstack=""
end
end
end
px=word(cstack,1)
if words(cstack)>1 then cstack=strip(delstr(cstack,1,length(px)))
else do
stacked=0;cstack=""
end
if arg(1)=OneChar then do
if datatype(px,'N') then py=px
else py=upper(left(px,1))
end
else py=px
return strip(py)
Kprint: return writeln('bd',arg(1))
send:
if debug then call writech(STDOUT,arg(1))
else do
'Print' quote||arg(1)||quote
'Send' quote||arg(1)||quote
end
return
uprompt:
if ~timeup then do
elapsed=time('e')
remaining=TimeLimit-(elapsed/60)
if elapsed>=(TimeLimit*60)-120 then call send(BOLD||NL' You have 'trunc(remaining)' Minutes remaining'AOFF||NL)
if elapsed>=(TimeLimit*60) then do
timeup=1
call send(BOLD||NL' Poof! Your time is up!'AOFF||NL)
if marks>0 then signal download
else signal nomarkexit
end
end
if debug then do
options prompt arg(1)
parse pull u
return translate(u," ",",;")
end;else do
'Print' quote||arg(1)||quote
'Send' quote||arg(1)||quote
'GetInbound E0 'InputTimeout
'String $(event)'
if upper(RESULT)='CARRIER' then do
call cleanup
exit 10
end;else if upper(RESULT)='TIMEOUT' then do
call send(NL' User Input TIMEOUT:'timeouts||NL)
timeouts=timeouts+1
if timeouts>MaxTimeouts then do
call send(' Sorry, you have made too many input timeouts, bye')
call cleanup
exit 10
end
end;else if upper(RESULT)='LOGIN' then do
'String $(namebuf)'
u=translate(RESULT," ",",;")
end;else u=""
end
return u
left_justify:
if length(arg(1))>arg(2) then return (left(arg(1),arg(2)))
else return (arg(1)||copies(" ",arg(2)-length(arg(1))))
right_justify:
if length(arg(1))>arg(2) then return (right(arg(1),arg(2)))
else return (copies(" ",arg(2)-length(arg(1)))||arg(1))
get_fn:
if LastPos('/',arg(1))~=0 then return SubStr(arg(1),LastPos('/',arg(1))+1)
else if LastPos(':',arg(1))~=0 then return SubStr(arg(1),LastPos(':',arg(1))+1)
else return arg(1)
addslash:
curr=arg(1)
select
when right(curr, 1)=":" then nop
when right(curr, 1)="/" then nop
otherwise curr=curr"/"
end
return curr
dequote:
parse arg thing
parse var thing '"' unq_thing '"'
if unq_thing ~= "" then return unq_thing
return thing
break_c:
if upper(uprompt(NL||' Are you sure you want to Exit? '))=="N" then return
break_d:
halt:
ioerr:
call cleanup()
exit 10
/**/